import service from '@/utils/request.js'

// 管理员登录
export function adminLogin(username, password){
    return service({
        url:'/api/admin/login',
        method:'post',
        data:{
            username,
            password
        }
    })
}

// 重置密码
export function forget(username){
    return service({
        url:'/api/admin/forget',
        method:'post',
        params:{
            username
        }
    })
}

// 获取登录人信息
export function getAdminInfo(id){
    return service({
        url:'/api/admin/' + id,
        method:'get'
    })
}

// 获取电影列表
export function getFilmList(type, region){
    return service({
        url: '/api/film/' + type + "/" + region,
        method:'get'
    })
}

// 修改电影信息
export function reviseFilm(id,name,releaseTime,type,status,region,hot,introduction,cover,duration){
    return service({
        url:'/api/film',
        method:'put',
        data:{
            id,
            name,
            releaseTime,
            type,
            status,
            region,
            hot,
            introduction,
            cover,
            duration
        }
    })
}

// 删除电影
export function removeFilm(id){
    return service({
        url:'/api/film/' + id,
        method:'delete'
    })
}

// 电影排片
export function arrgementFilm(fid, name, seatNumber, price, type, date, startTime,
    endTime, founder){
        return service({
            url:'/api/arrangement',
            method:'post',
            data:{
                fid,
                name,
                seatNumber,
                price,
                type,
                date,
                startTime,
                endTime,
                founder
            }
        })
    }

// 模糊查询
export function query(name){
    return service({
        url:'/api/film/name/' + name,
        method:'get'
    })
}

// 查看排片列表
export function getArrangement(){
    return service({
        url:'/api/arrangement',
        method:'get',
    })
}

// 修改排片信息
export function editArrangement(id,
    fid,
    name,
    seatNumber,
    boxOffice,
    price,
    type,
    date,
    startTime,
    endTime,
    founder){
    return service({
        url:'/api/arrangement',
        method:'put',
        data:{
            id,
            fid,
            name,
            seatNumber,
            boxOffice,
            price,
            type,
            date,
            startTime,
            endTime,
            founder
        }
    })
}

// 排片信息模糊查询
export function likeArrangement(name){
    return service({
        url:'/api/arrangement/like/' + name,
        method:'get'
    })
}

// 删除排片信息
export function removeArr(id){
    return service({
        url:'/api/arrangement/' + id,
        method:'delete',
    })
}

// 新增电影
export function addFilm(name, releaseTime, type, status,
    region, introduction, hot, cover, duration){
        return service({
            url:'/api/film',
            method:'post',
            data:{
                name,
                releaseTime,
                type,
                status,
                region,
                introduction,
                hot,
                cover,
                duration
            }
        })
    }

// 查询轮播图列表
export function getPoster(){
    return service({
        url:'/api/poster',
        method:'get'
    })
}

// 上传新的轮播图
export function addPoster(title, url, status){
    return service({
        url:'/api/poster',
        method:'post',
        data:{
            title,
            url,
            status
        }
    })
}

// 更新轮播图信息
export function updatePoster(id, title, url, status){
    return service({
        url:'/api/poster',
        method:'put',
        data:{
            id,
            title,
            url,
            status
        }
    })
}

// 删除轮播图
export function deletePoster(id){
    return service({
        url:'/api/poster/' + id,
        method:'delete'
    })
}

// 获取所有用户信息
export function getAllUser(){
    return service({
        url:'/api/user',
        method:'get'
    })
}

// 修改用户密码
export function updateUser(id, username, password, avatar, nickname, email, birthday, gender, info){
    return service({
        url:'/api/user',
        method:'put',
        data:{
            id,
            username,
            password,
            avatar,
            nickname,
            email,
            birthday,
            gender,
            info
        }
    })
}

// 删除用户
export function deleteUser(id){
    return service({
        url:'/api/user/delete/' + id,
        method:'delete'
    })
}

// 获取订单信息
export function getOrder(){
    return service({
        url:'/api/order',
        method:'get'
    })
}

// 修改订单信息
export function revokeOrder(id,uid,phone,aid,seats,
    price,status,createAt,payAt){
        return service({
            url:'/api/order',
            method:'put',
            data:{
                id,
                uid,
                phone,
                aid,
                seats,
                price,
                status,
                createAt,
                payAt
            }
        })
    }

// 添加异常订单
export function exportErr(oid, reason, reviewer){
    return service({
        url:'/api/oe',
        method:'post',
        data:{
            oid,
            reason,
            reviewer
        }
    })
}

// 查询异常订单列表
export function getErrList(){
    return service({
        url:'/api/oe',
        method:'get'
    })
}

// 处理异常订单
export function handleErrOrder(id,oid,reason,reviewer,
    status,result,createAt){
        return service({
            url:'/api/oe',
            method:'put',
            data:{
                id,
                oid,
                reason,
                reviewer,
                status,
                result,
                createAt
            }
        })
    }

// 获取所有员工信息
export function getAllWorker(){
    return service({
        url:'/api/worker',
        method:'get'
    })
}

// 修改员工信息
export function updateWorker(id,username,password,
    nickname,gender,phone,avatar,entry,department,
    creatAt){
        return service({
            url:'/api/worker',
            method:'put',
            data:{
                id,
                username,
                password,
                nickname,
                gender,
                phone,
                avatar,
                entry,
                department,
                creatAt
            }
        })
}

// 删除员工
export function removeWorker(id){
    return service({
        url:'/api/worker/' + id,
        method:'delete'
    })
}

// 新增员工信息
export function addWorker(username,password,nickname,
    gender,phone,avatar,entry,department){
        return service({
            url:'/api/worker',
            method:'post',
            data:{
                username,
                password,
                nickname,
                gender,
                phone,
                avatar,
                entry,
                department
            }
        })
    }

// 更新管理员信息
export function updataAdmin(id,password,avatar,username){
    return service({
        url:'/api/admin/update',
        method:'post',
        data:{
            id,
            password,
            avatar,
            username
        }
    })
}